package com.horay.springbootdemo.response.body.advice.api.controller;

import com.horay.springbootdemo.common.result.ResultBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ResponseBodyAdvice控制器
 *
 * @author heyingcheng
 * @date 2019/8/31 9:23
 */
@Slf4j
@RestController
@RequestMapping("response/body/advice")
public class ResponseBodyAdviceController {

    @GetMapping(value = "byte")
    public Byte bytes() {
        return 1;
    }

    @GetMapping(value = "short")
    public Short shorts() {
        return 11;
    }

    @GetMapping(value = "int")
    public Integer ints() {
        return 111;
    }

    @GetMapping(value = "long")
    public Long longs() {
        return 1111L;
    }

    @GetMapping(value = "float")
    public Float floats() {
        return 1111.11F;
    }

    @GetMapping(value = "double")
    public Double doubles() {
        return 1111.111D;
    }

    @GetMapping(value = "boolean")
    public Boolean booleans() {
        return false;
    }

    @GetMapping(value = "char")
    public Character chars() {
        return new Character('c');
    }

    @GetMapping(value = "string")
    public ResultBody<String> string() {
        return new ResultBody<>("response/body/advice/string");
    }

    @GetMapping("collection")
    public List<String> collection() {
        return Arrays.asList("response", "body", "advice");
    }

    @GetMapping("map")
    public Map<String, Object> map() {
        Map<String, Object> map = new HashMap<>(1);
        map.put("collection", Arrays.asList("response", "body", "advice"));
        return map;
    }

}
